<%-- 
    Document   : falls
    Created on : Dec 9, 2009, 10:27:36 PM
    Author     : djorge
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.Enumeration" %>
<jsp:useBean class="Cliente.WebGestor" id="webMyTwi" scope="session"/>

<%

Enumeration<String>flag=request.getParameterNames();
while(flag.hasMoreElements()){
    String opera=flag.nextElement();
    System.out.println(opera+":"+request.getParameter(opera));
}

String username = null;
String [] details = null;
String [] followers = null;
String [] following = null;
String [] myTwee = null;
String local = "";
String name = "";

if ("Select".equalsIgnoreCase(request.getParameter("select"))){
    username = request.getParameter("users");
    System.out.println("Nickname:"+username);
    //Recoler detalhes
    details = webMyTwi.getGereAdmin().recolheTodosDetalhes(username, "detalhes");
    name = details[1];
    local = details[2];

    //Following e followers
    following = webMyTwi.getGereAdmin().recolheTodosDetalhes(username, "following");
    followers = webMyTwi.getGereAdmin().recolheTodosDetalhes(username, "followers");
    System.out.println("---Followers---");
    for(int i=0; i<followers.length; i++){
        System.out.println(followers[i]);
    }
    System.out.println("---Following---");
    for(int i=0; i<following.length; i++){
        System.out.println(following[i]);
    }

    //Os meus tweets
    myTwee = webMyTwi.getGereAdmin().recolheTodosDetalhes(username, "meusTwee");
    System.out.println("---MyTwi---");
    for(int i=0; i<myTwee.length; i++){
        System.out.println(myTwee[i]);
    }
}
String op = request.getParameter("select");
boolean est = false;

System.out.println("OOOOPPPPEEEERRRRACCAAAAOO:"+op);
if ("Delete".equalsIgnoreCase(op)) {
    System.out.println("A remover utilizador...");
    username = request.getParameter("users");
    est = webMyTwi.getGereAdmin().apagaCliente(username);
    if (est = true) {
        System.out.println("JSP:Removido com sucesso!!!");
    } else {
        System.out.println("BODE!!!");
    }
}

%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <table>
            <tbody>
                <tr>
                    <td><img src="IMG/mytwitter-followers.png" width="94" height="14" alt="mytwitter-followers"/>
                        <select name="followers" size="4" disabled style="background:transparent; background-image:url(IMG/bg-txt.png);background-repeat:repeat">
                            <%
                                int i;
                                if(followers!=null){
                                    System.out.println("Tamanho:"+followers.length);
                                    for(i=1; i<followers.length; i++){
                                        %>
                                        <option style="color:gray"> <%=followers[i]%> </option>
                                        <%
                                    }
                                }
                            %>
                            <option style="color:gray">______________________</option>
                        </select>
                    </td>
                    <td><img src="IMG/mytwitter-following.png" width="88" height="19" alt="mytwitter-following"/>
                        <select name="following" size="4" disabled style="background:transparent; background-image:url(IMG/bg-txt.png);background-repeat:repeat">
                            <%
                                if(following!=null){
                                    System.out.println("Tamanho:"+following.length);
                                    for(i = 1; i<following.length; i++){
                                        %>
                                        <option style="color:gray"> <%=following[i]%> </option>
                                        <%
                                    }
                                }
                            %>
                            <option style="color:gray">______________________</option>
                        </select>
                    </td>
                    <td>
                        <textarea name="details" rows="1" cols="20" readonly="readonly" style="color:gray; text-align:justify; background:transparent; background-image:url(IMG/bg-txt.png);background-repeat:repeat">
Name: <%= name %>
Local: <%= local %></textarea>
                    </td>
                </tr>
            </tbody>
        </table>
        <textarea name="timeline" rows="5" cols="80" readonly="readonly" style="color:gray; text-align:justify; background:transparent; background-image:url(IMG/bg-txt.png);background-repeat:repeat"><%
            if(myTwee!=null){
                for (i = 1; i < myTwee.length; i++){
                    %><%=myTwee[i]+"\n"%><%
                }
            }
        %></textarea>
    </body>
</html>
